package com.bsj.travel.mqtt.config;

import net.dreamlu.iot.mqtt.core.server.model.Message;
import net.dreamlu.iot.mqtt.core.server.serializer.IMessageSerializer;
import org.tio.utils.json.JsonUtil;

/**
 * @author yinhao
 * @version 1.0
 * @description jackson 消息序列化
 * @date 2023/11/9
 */
public class JacksonMessageSerializer implements IMessageSerializer {


    @Override
    public byte[] serialize(Message message) {
        return JsonUtil.toJsonBytes(message);
    }

    @Override
    public Message deserialize(byte[] bytes) {
        return JsonUtil.readValue(bytes, Message.class);
    }
}
